<extend name="./Application/Admin/View/common/base.html" />
<block name="crumb">
    <span class="c-gray en">&gt;</span> 代理中心
    <span class="c-gray en">&gt;</span> 客户资源
</block>

<block name="content">
    <div class="tabBar cl m-b-10">
        <span><a href="{:U('Members/members')}">客户列表</a></span>
        <span><a href="{:U('Members/add_member')}">添加客户</a></span>
        <span class="current"><a href="{:U('Members/assign_member')}">客户分配</a></span>
    </div>

    <div class="text-c">
        <form class="Huiform" method="get" action="" >
            <input type="text" placeholder="客户名称/微信/手机" value="{$_GET['cName']}" class="input-text" style="width:150px" name="cName"/>

            <input type="hidden" name="m" value="admin"/>
            <input type="hidden" name="c" value="members"/>
            <input type="hidden" name="a" value="assign_member"/>
            <button type="submit" class="btn btn-success"><i class="Hui-iconfont"></i> 查询</button>
        </form>
    </div>

    <div class="mt-10">
        <table class="table table-border table-bordered table-bg table-sort table-hover">
            <form method="post" action="{:U('Members/doAssign')}" id="assign_form">
                <thead>
                <tr>
                    <td colspan="7">
                        <input type="text" placeholder="输入代理名字搜索" class="input-text w-200" id="search_to"/>
                        <select name="agent_id" id="to" class="input-text w-150" style="position:relative;top:2px;">
                            <option value="">-- 请选择 --</option>
                        </select>
                        <button type="button" class="btn btn-primary" id="assign">分配</button>
                    </td>
                </tr>
                <tr class="text-c">
                    <th><input type="checkbox" id="check_all"/></th>
                    <th>客户名</th>
                    <th>手机号</th>
                    <th>微信</th>
                    <th>客户地址</th>
                    <th>接收代理</th>
                    <th>接收时间</th>
                </tr>
                </thead>
                <tbody>
                <volist name="members" id="mem">
                    <tr class="text-c">
                        <td><input type="checkbox" class="check_list" name="member_id[]" value="{$mem['member_id']}"/></td>
                        <td>{$mem['member_name']}</td>
                        <td>{$mem['mobile']}</td>
                        <td>{$mem['wx']}</td>
                        <td>{$mem['address']}</td>
                        <td>{$mem['agent_name']}</td>
                        <td>{$mem['send_time']}</td>
                    </tr>
                </volist>
                </tbody>
            </form>
        </table>
    </div>
    <div class="page" style="margin-top: 10px;">{$page}</div>
</block>

<!--自己的css和js-->
<block name="css">
    <link href="__PUBLIC__/Admin/static/ext/css/zoomify.css" rel="stylesheet" type="text/css" />
</block>
<block name="js">
    <script type="text/javascript" src="__PUBLIC__/Admin/static/ext/js/zoomify.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#search_to").keyup(function(){
                $aName = $(this).val();
                if($aName != ''){
                    getAgentName();
                }else{
                    return false;
                }
            });

            $("#assign").click(function(){
                $to = $("#to").val();
                if($to == '' || !$to){
                    layer.alert("请选择代理");
                    return false;
                }else{
                    $("#assign_form").submit();
                }
            });

            $("#search_to").change(function(){
                $aName = $(this).val();
                if($aName != ''){
                    getAgentName();
                }else{
                    return false;
                }
            });

            function getAgentName()
            {
                $.ajax({
                    url: "{:U('Members/searchAgent')}",
                    type: "post",
                    data: {aName : $aName},
                    success: function (data) {
                        if (data) {
                            options = "";
                            $.each(data, function(k, v){
                                options += '<option value="'+ v.agent_id +'">'+ v.agent_name +'</option>';
                            });
                            $("#to").html(options);
                        }
                    }
                });
            }
        });
    </script>
</block>



